import "./infoWindow.css"

// //单例模式，整个页面只需要一个弹窗
// const infoWindow= (function () {
//     // 声明WindowClass对象，无法在外部直接调用

//     // 声明一个instance对象
//     var instance; 
//     return function (viewer) {
//         if (instance) { // 如果已存在 则返回instance
//             return instance;
//         }
//         instance = new WindowClass(viewer) // 如果不存在 则new一个
//         return instance;
//     }
// })();
var WindowClass = function(viewer) {
    this.viewer = viewer
    this.init()
};
WindowClass.prototype = {
    init: function() {
        this.Div = document.createElement("div");
        this.Div.id = "widget-infoWinfows-cesium"
        this.Div.className = "widget-infoWinfows"
        var bodydom = this.viewer.container
        bodydom.appendChild(this.Div);
    },
    show: function(title, content, GuiShu) {
        var self = this
        if (!document.getElementById("widget-infoWinfows-cesium")) {
            this.init()
        }
        this.Div.innerHTML = `
        <div class="infoWinfows-title">
            <div class="infoWinfows-left">${GuiShu}</div>
            <div class="infoWinfows-right"><span class="widget-icon-close" id="widget-infoWinfows-cesium-close"></span></div>
        </div>
        <div class="infoWinfows-content">
            ${content}
        </div>`;
        $("#widget-infoWinfows-cesium-close").click(function() {
            self.close()
        })
        this.Div.classList.remove('bounceOutRight'); // 删除
        this.Div.classList.add('animated');
        this.Div.classList.add('bounceInRight'); // 添加
    },
    close: function() {
        this.Div.classList.add('bounceOutRight'); // 删除
        this.Div.classList.remove('bounceInRight'); // 删除
        this.Div.classList.remove('animated'); // 删除
        this.Div.innerHTML = ""
    }
}
export default WindowClass